package com.xframe.common.core.service.login;

import com.xframe.domain.role.IUserCredentials;
import com.xframe.common.core.constant.ErrorConstant;
import com.xframe.common.core.dto.ErrorCode;
import com.xframe.common.core.exception.BusinessException;

/**
 * 功能描述: 禁止重复登录,
 *
 * @author xufeng
 * @version 1.0
 * @date 2023-5-31
 */
public class FristRepeatLoginstrategy implements IRepeatLoginstrategy {
    @Override
    public void proc(ITokenService tokenService, IUserCredentials userCredentials) {
        // 重复登录 禁止  第一个登录凭证还在存在打情况下 直接抛出异常
        if(userCredentials != null){
            throw new BusinessException(ErrorCode.ACCOUNT_EXISTS_LOGIN,
                    ErrorConstant.ACCOUNT_EXISTS_LOGIN_MSG);
        }
    }
}
